import globalConfig from '@/core/framework/config/globalConfig'
import serverApiUtils from '@/core/utils/serverApiUtils'
import lodash from 'lodash'
import { R } from '@/components/axios/interface'
import { AxiosRequestConfig } from 'axios'
import http from '@/components/axios/http'
import IamAccountProfileResponse from '@/core/account/generated/types/model/response/IamAccountProfileResponse'
import accountApiConfig from '@/core/account/apiconfig/accountApiConfig'

class AccountProfileApi {
	getByCurrentAccount = (accessToken: string): Promise<R<IamAccountProfileResponse>> => {
		const config = lodash.merge(
			{ headers: { [globalConfig.authorizationKey]: accessToken } } as AxiosRequestConfig,
			serverApiUtils.convertApiConfig(accountApiConfig.admin.iamAccountProfileGetByCurrentAccount),
		)
		return http.get(config)
	}
}

export default new AccountProfileApi()
